package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @description:用户端带查询条件的排班信息
 * @author :又菜又爱玩的→速趴塞亚锦←
 * @create :2023/5/20
 * @param  :1.8
 */
@RestController
@RequestMapping("/user/hosp/schedule")
public class UserScheduleController {


    @Resource
    private ScheduleService scheduleService;

    @GetMapping("/{hoscode}/{depcode}/{pageNum}/{pageSize}")
    public R getSchedulePage(@PathVariable String hoscode,
                             @PathVariable String depcode,
                             @PathVariable Integer pageNum,
                             @PathVariable Integer pageSize){//分页

        Map<String,Object> map=scheduleService.getSchedulePageByCondition(hoscode,depcode,pageNum,pageSize);
        return R.ok().data( map);
    }


    @GetMapping("/{scheduleId}")
    public ScheduleOrderVo getScheduleById(@PathVariable(value = "scheduleId") String scheduleId){
        return scheduleService.getScheduleById(scheduleId);
    }


    /**
     * @description:________根据排班id获取当天医生的详情信息||获取就诊人信息已经在PatientController里面的（查）方法完成
     * @author :又菜又爱玩的→速趴塞亚锦←
     * @create :2023/5/20
     * @param  :1.8
     */
    @GetMapping("/info/{scheduleId}")
    public R getScheduleInfo(@PathVariable String scheduleId){
        Schedule schedule=scheduleService.getScheduleInfo(scheduleId);
        return R.ok().data("schedule",schedule);
    }

    //查询显示当天工作的医师的排班详情信息
    @GetMapping("/{hoscode}/{depcode}/{workdate}")
    public R getScheduleDetail(@PathVariable String hoscode,
                               @PathVariable String depcode,
                               @PathVariable String workdate){

        List<Schedule> details = scheduleService.detail(hoscode, depcode, workdate);

        return R.ok().data("details",details);
    }
}
